<template>
	<view>
		<uNavbar title="关注的品牌"></uNavbar>
		<view class="follow ">
			<view class="follow_box  flex_ZC" v-for="(item,index) in followList"  :key="index" @click="goBrand(item.brand_id)">
				<image :src="item.brand.logo" mode=""></image>
				<text class="c3">{{item.brand.name}}</text>
			</view>
		</view>
		<!-- 暂无数据 / 加载更多 -->
		<noDatas :xxxList="followList" :status="status"></noDatas>
	</view>
</template>

<script>
	import {followList} from '../../api/store.js'
	export default {
		data() {
			return {
				page: 1,
				size: 20,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				followList:[],
			}
		},
		onLoad() {
			this.initList()
		},
		methods: {
			// 我的关注
			initList() {
				let data = {
					page: this.page,
				}
				followList(data).then(res => {
					console.log(res)
					if(res.code == 1){
						let list = res.data.data;
						this.followList = this.page == 1 ? list : this.followList.concat(list);
						console.log(this.followList);
						if (list.length < this.size) this.status = 'nomore';
					}
				})
			},
			// 去品牌详情
			goBrand(id){
				console.log(id);
				uni.navigateTo({
					url: '/pagesMy/brandCenter/brandHomepage?id=' + id
				})
			},
		},
		// 下拉刷新
		onPullDownRefresh() {
			console.log('下拉刷新');
			let that = this;
			setTimeout(function() {
				that.page = 1,
					that.followList = [],
					that.initList()
			}, 800);
		},
		//触底加载
		onReachBottom() {
			console.log('触底加载');
			if (this.status != 'nomore') {
				this.page = this.page + 1
				this.initList()
			}
		}
	}
</script>

<style scoped>
.follow{
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	width: 690rpx;
	margin: 30rpx auto ;
}
.follow_box{
	width: 33%;
	margin: 30rpx 0;
	font-size: 28rpx;
}
.follow_box>image{
	width: 124rpx;
	height: 124rpx;
	border-radius: 50%;
	margin-bottom: 24rpx;
}

</style>